﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Sapro_Project
{
    public partial class ListMateria : PhoneApplicationPage
    {
        List<Grid> nomesMat = new List<Grid>();
        TextBlock nome;
        Button excEsc;
        Button editEsc;
        public ListMateria()
        {
            InitializeComponent();
        }
        private void ContentPanel_Loaded(object sender, RoutedEventArgs e)
        {
            foreach (Materias esc in Fachada.ObterFachada().BuscaMateria())
            {
                nome = new TextBlock();
                excEsc = new Button();
                editEsc = new Button();
                Grid ret = new Grid();
                nome.MouseLeftButtonDown += delegate(object ob, MouseButtonEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Gray);

                };
                nome.MouseLeftButtonUp += delegate(object ob, MouseButtonEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Transparent);
                    NavigationService.Navigate(new Uri("/ListMateria.xaml", UriKind.RelativeOrAbsolute));
                };
                nome.MouseMove += delegate(object ob, MouseEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Transparent);
                };
                nome.MouseLeave += delegate(object ob, MouseEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Transparent);
                };
                Thickness tk0 = new Thickness();
                tk0.Top = 18;
                tk0.Left = 18;
                nome.Margin = tk0;
                nome.FontSize = 30;
                nome.Foreground = new SolidColorBrush(Colors.Black);
                nome.Text = "" + esc.Nome;
                editEsc.Content = "ed";
                editEsc.Width = 75;
                Thickness tk = new Thickness();
                tk.Left = 234;
                tk.Top = 3;
                editEsc.Margin = tk;
                excEsc.Content = "ex";
                excEsc.CommandParameter = 1;
                excEsc.Width = 75;
                Thickness tk2 = new Thickness();
                tk2.Left = 354;
                tk2.Top = 3;
                excEsc.Margin = tk2;
                String nm = esc.Nome;
                excEsc.Click += delegate(object s, RoutedEventArgs ev)
                {
                    MessageBox.Show(nm);
                };
                ret.Width = 430;
                ret.Children.Add(nome);
                ret.Children.Add(editEsc);
                ret.Children.Add(excEsc);
                nomesMat.Add(ret);
            }
            list_materia.ItemsSource = nomesMat;
        }
    }
}
